package com.whmnx.base.utils;

import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.whmnx.base.R;
import com.whmnx.base.constants.Constants;


/**
 * author : huang
 * date   : 2019/10/29 0029 17:43
 * version: 1.0
 * @author Administrator
 */
public class ImageUtil {

        public static void setImage(ImageView imageView, String url) {     // 磁盘缓存策略
            // 不使用磁盘缓存 override(680);
            RequestOptions  options = new RequestOptions().placeholder(R.mipmap.zhangwei).override(580).dontAnimate().diskCacheStrategy(DiskCacheStrategy.NONE);

        if (!TextUtils.isEmpty(url) && url.contains("http")){
                Glide.with(imageView.getContext()).load(url)
                        .apply(options)
                        .into(imageView);
        }else {
            RequestOptions   options2 = new RequestOptions().error(R.mipmap.logo3).override(580).dontAnimate();
            Glide.with(imageView.getContext()).load(Constants.HOST + url)
                    //   .transition(withCrossFade())
                    .apply(options2)
                    .into(imageView);
        }
    }
}
